package com.bytenebula.asteroid.controller;

import com.bytenebula.asteroid.ResponseResult;
import com.mybatisflex.core.paginate.Page;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import com.bytenebula.entity.meta.MetaRelationshipCondition;
import com.bytenebula.asteroid.service.MetaRelationshipConditionService;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 *  控制层。
 *
 * @author patrick
 * @since 2024-09-15
 */
@RestController
@RequestMapping("/metaRelationshipCondition")
@ResponseResult
public class MetaRelationshipConditionController {

    @Autowired
    private MetaRelationshipConditionService metaRelationshipConditionService;

    /**
     * 添加。
     *
     * @param metaRelationshipCondition 
     * @return {@code true} 添加成功，{@code false} 添加失败
     */
    @PostMapping("save")
    public boolean save(@RequestBody MetaRelationshipCondition metaRelationshipCondition) {
        return metaRelationshipConditionService.save(metaRelationshipCondition);
    }

    /**
     * 根据主键删除。
     *
     * @param id 主键
     * @return {@code true} 删除成功，{@code false} 删除失败
     */
    @DeleteMapping("remove/{id}")
    public boolean remove(@PathVariable Integer id) {
        return metaRelationshipConditionService.removeById(id);
    }

    /**
     * 根据主键更新。
     *
     * @param metaRelationshipCondition 
     * @return {@code true} 更新成功，{@code false} 更新失败
     */
    @PutMapping("update")
    public boolean update(@RequestBody MetaRelationshipCondition metaRelationshipCondition) {
        return metaRelationshipConditionService.updateById(metaRelationshipCondition);
    }

    /**
     * 查询所有。
     *
     * @return 所有数据
     */
    @GetMapping("list")
    public List<MetaRelationshipCondition> list() {
        return metaRelationshipConditionService.list();
    }

    /**
     * 根据主键获取详细信息。
     *
     * @param id 主键
     * @return 详情
     */
    @GetMapping("getInfo/{id}")
    public MetaRelationshipCondition getInfo(@PathVariable Integer id) {
        return metaRelationshipConditionService.getById(id);
    }

    /**
     * 分页查询。
     *
     * @param page 分页对象
     * @return 分页对象
     */
    @GetMapping("page")
    public Page<MetaRelationshipCondition> page(Page<MetaRelationshipCondition> page) {
        return metaRelationshipConditionService.page(page);
    }

}
